const app = getApp()
const WXAPI = require('../../../../api/newApi')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgHttp: app.globalData.imgHttp, //图片前缀
    detail:{},
    subscribeShow: true, //订阅消息弹窗
    tmplIds: [], //订阅消息数组
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.getSetting({
      withSubscriptions: true,
      success (res) {
        console.log('res.authSetting',res.authSetting)
        console.log('res',res)
        console.log('res.subscriptionsSetting',res.subscriptionsSetting)
        console.log('res.subscriptionsSetting.itemSettings',res.subscriptionsSetting.itemSettings)
        if (res.subscriptionsSetting.itemSettings==undefined||res.subscriptionsSetting.itemSettings=='undefined') {
          console.log('没有点击总是保持以上选择')
        }else{
          console.log('点击了总是保持以上选择')
          console.log(res.subscriptionsSetting.itemSettings['WPUobfJMs5-ULdzSXGFoXxCCNQUl8n6GZYJF7M9V5ts'])
        }
      }
    })
    this.setData({
      statusHeight: app.gettop.height,
      status: app.gettop.status,
      navHeight: app.gettop.navHeight,
      mobbleBottom: app.mobile.mobbleBottom,
    })
    var detail = JSON.parse(options.detail);
    this.data.detail = detail
    console.log(detail)
    var cardType = options.cardType
    this.setData({
      detail: detail,
      cardType
    })
    this.getSubscriptionLs()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  // 查询订阅模版id
  getSubscriptionLs() {
    var data = {
      paySource: app.globalData.paySource,
      cardType: this.data.cardType
    }
    WXAPI.subscriptionLs(data, (res) => {
      if (res.code == 200) {
        this.setData({
          tmplIds: res.result
        })
      }
    })
  },
  handleChose(){
    wx.reLaunch({
      // url: '../../../../pages/assets/assets',
      // url:'/pages/abulkPage/abulkPage'
      url: '/pages/userMarket/userMarket',
    })
  },
  watchCard(){ //查看卡详情
    wx.navigateTo({
      url: '../../../../ecCanvas/pages/myShareholderCard/otherCarddetail/otherCarddetail?assetId=' + this.data.detail.assetId + '&id=' + this.data.detail.id,
    })
  },
})